<%@page import="java.util.ArrayList,projectodedalo.modelo.Idea"%>
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
	pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>:: Buscar Ideas ::</title>
<script type="text/javascript" src="lib/alertify.js"></script>
<link rel="stylesheet" href="themes/alertify.core.css" />
<link rel="stylesheet" href="themes/alertify.default.css" />
	<script src="js/jquery-1.3.2.min.js"></script>
	<script>
		$(document).ready(function() {
		
			/*   		$("#myModal").on("show.bs.modal", function(e) {
			 var ideaId = $(e.relatedTarget).data('idea-id');
			 var ideaTit = $(e.relatedTarget).data('idea-tit');
			 $(e.currentTarget).find('input[name="ideaId"]').val(ideaId);
			 $(e.currentTarget).find('input[name="ideaTit"]').val(ideaTit);
			 $(e.currentTarget).find('input[name="ideaTit"]').val(ideaTit);    
			 });   
			 */
		
			/* 
				Antes de mostrar la ventana modal, recuperar los valores dat-* del link que lo invoca
			 	almacenar cada valor en el control correspondiente de la ventana modal
			 */
		
			$('#myModal').on('show.bs.modal', function(event) {
				$("#ideaId").val($(event.relatedTarget).data('idea-id'));
				$("#ideaTit").val($(event.relatedTarget).data('idea-tit'));
				$("#ideaDes").val($(event.relatedTarget).data('idea-des'));
			});
		
		});
		
		$(window).load(function() {
			  $( "#menu11" ).addClass( "inactive" ); //discutirIdeas.jsp
			  $( "#menu12" ).addClass( "inactive" ); //registrarReuniones.jsp
			  $( "#menu21" ).addClass( "active" ); //buscarIdeas.jsp
			  $( "#menu22" ).addClass( "inactive" ); //evaluarIdeas.jsp
		});
	</script>
</head>
<body>
	<jsp:include page="cabecera.jsp" flush="true" />
	<div class="container">
		<form class="form-horizontal well" method="post" action="BuscarIdeasServlet">
			
				<div class="alert alert-info alert-coupon" align="center"
					style="font-weight: bold;">.:. BUSCAR IDEAS .:.</div>
				<!-- <div class="table-responsive"> -->
				<div class="control-group">
					<label class="control-label" for="multiSelect">Texto de
						Busqueda </label> <input type="text" name="txtPalabrasBusqueda" /> <label
						class="control-label" for="multiSelect">Por Estado :</label> <select
						name="porEstado">
						<option value=0>Todos</option>
						<option value=PUBLICADA>Publicadas</option>
						<option value=APROBADA>Aprobadas</option>
						<option value=RECHAZADA>Rechazadas</option>
					</select> <input type="submit" value="Buscar" />
				</div>

				<div class="panel panel-default">
					<div class="panel-heading">Resultado de la Busqueda</div>
					<div class="panel-body">
						<table
							class="table table-condensed table-striped table-bordered table-hover no-margin">
							<thead>
								<tr>
									<th align="center" style="width: 5%">ID</th>
									<th style="width: 20%" class="hidden-phone">Titulo</th>
									<th style="width: 50%" class="hidden-phone">Descripci&oacute;n</th>
									<th style="width: 5%" class="hidden-phone">Estado</th>
									<th style="width: 5%" class="hidden-phone">Accion</th>
								</tr>
							</thead>
							<!-- fin de thead -->
							<tbody>
	<%
	ArrayList<Idea> ideas = (ArrayList<Idea>) request.getAttribute("LISTA");
	if (ideas != null) {
	%>	
        <script>
			 alertify.success("Se recuperaron <%= ideas.size() %> fila(s)");
		</script>		
	<%
		for (Idea dd2 : ideas) {
	%>
		<tr>	
			<td >
			<a href="<%= request.getContextPath() %>/MostrarIdeaServlet?id=<%= dd2.getIdIdea() %>"><%= dd2.getIdIdea() %></a>
			</td>
			<td ><%=  dd2.getTituloIdea()  %></td>
		    <td ><%=  dd2.getDescripcionIdea()  %></td>
		    <td ><%=  dd2.getEstado()  %></td>
		    <td>
		    <% 
		    	if (dd2.getEstado().equals("PUBLICADA")) { // Activar link solo para publicados
		    %>
		    	<a href="<%=request.getContextPath() %>/EvaluarIdeaServlet?id=<%= dd2.getIdIdea() %>">Evaluar</a>
	<%
				}
	%>	
		    </td>
		 </tr>
	<%
		}
	}
	%>
							</tbody>
							<!-- fin de tbody -->
						</table>
						<!-- fin de table -->
					</div>
				</div>
				<!-- fin de div-panel -->
				<footer>
				<p>&copy; Dedalo 2014.</p>
				</footer>
			</div>
		</form>
</body>
</html>